import smCrypto from 'sm-crypto'

export const sm2Encryption = (password: string) => {
  const sm2 = smCrypto.sm2
  const publicKey =
    '043628991c90fd4eb7b4553bdfe330fe390c947f82d012d557a1ea4c475d9916a8bff080ddf94da9e2c044ae829eec00e3a1d35458e841d23f629626e9b492c32c'
  // 加密
  return sm2.doEncrypt(password, publicKey, 1)
}

/**
 * @description 解密
 */
export const sm2Decryption = (data: string) => {
  const sm2 = smCrypto.sm2
  const privateKey =
    '043628991c90fd4eb7b4553bdfe330fe390c947f82d012d557a1ea4c475d9916a8bff080ddf94da9e2c044ae829eec00e3a1d35458e841d23f629626e9b492c32c'
  return sm2.doDecrypt(data, privateKey, 1)
}

export const setRootFontSize = () => {
  const screenWidth = window.innerWidth
  const rootFontSize = (16 * screenWidth) / 1920
  document.documentElement.style.fontSize = rootFontSize.toString() + 'px'
}
